package com.zr.domain.sp.tool.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicRabbitConfig {
    private final static String man = "topic.man";
    private final static String woman = "topic.woman";

    @Bean
    public Queue firstQueue() {
        return new Queue(TopicRabbitConfig.man);
    }

    @Bean
    public Queue secondQueue() {
        return new Queue(TopicRabbitConfig.woman);
    }

    @Bean
    TopicExchange exchange() {
        return new TopicExchange("topicExchange");
    }

    @Bean
    Binding bindingExchangeMessage1(Queue firstQueue, TopicExchange exchange) {
        return BindingBuilder.bind(firstQueue).to(exchange).with("topic.#");
    }

    @Bean
    Binding bindingExchangeMessage2(Queue secondQueue, TopicExchange exchange) {
        return BindingBuilder.bind(secondQueue).to(exchange).with("topic.#");
    }
}
